package com.hzcx.app.simplechat.ui.friend.presenter;

import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.model.FriendModel;
import com.hzcx.app.simplechat.ui.friend.bean.FriendBean;
import com.hzcx.app.simplechat.ui.friend.bean.FriendRequestBean;
import com.hzcx.app.simplechat.ui.friend.contract.FriendContract;
import com.hzcx.app.simplechat.ui.friend.contract.FriendRequestContract;

import java.util.List;

public class FriendRequestPresenter extends BasePresenter<FriendRequestContract.View> implements FriendRequestContract.Presenter {


    /**
     * 获取好友请求列表
     *
     * @param context
     */
    @Override
    public void getFriendRequestList(Context context) {
        FriendModel.getFriendRequestList(context, new BaseDialogObserver<List<FriendRequestBean>>(context) {
            @Override
            protected void onSuccess(List<FriendRequestBean> data) {
                mView.friendRequestResult(data);
            }
        });
    }

    /**
     * 同意好友请求
     *
     * @param context
     * @param id
     * @param headPos
     * @param contentPos
     */
    @Override
    public void agreeFriendRequest(Context context, int id, int headPos, int contentPos) {
        FriendModel.agreeFriendRequest(context, id, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.agreeSuccess(headPos, contentPos);
            }
        });
    }
}
